from django.db import models


class Areas(models.Model):
    '''
    省市区的划分,关联的应该是自己,外键指向的应该是自己
    '''
    name = models.CharField(max_length=20,verbose_name='名称')
    parent= models.ForeignKey(to='self',on_delete=models.SET_NULL,
                              related_name='subs',null=True,blank=True,
                              verbose_name='上级行政区划分')

    class Meta:
        db_table = 'tb_areas'
        verbose_name = '行政区划'
        verbose_name_plural = '行政区划'

    def __str__(self):
        return self.name










